_observeChannels: function(observer, account, conn, channels,
dispatchOp, requests, context) {
let connPath = conn.get_object_path();
- let connName = conn.get_bus_name();
- let accountPath = account.get_object_path()
let len = channels.length;
for (let i = 0; i < len; i++) {
let channel = channels[i];
let [targetHandle, targetHandleType] = channel.get_handle();
- let props = channel.borrow_immutable_properties();
- let targetId = props[Telepathy.CHANNEL_NAME + '.TargetID'];
- let targetId = props[Tp.PROP_CHANNEL_TARGET_ID];
/* Only observe contact text channels */
if ((!(channel instanceof Tp.TextChannel)) ||
if (this._sources[connPath + ':' + targetHandle])
continue;
- let source = new Source(accountPath, connPath,
- channel.get_object_path(),
- targetHandle, targetHandleType, targetId);
+ let source = new Source(account, conn, chan);
+
this._sources[connPath + ':' + targetHandle] = source;
source.connect('destroy', Lang.bind(this,
function() {
let iconBox = new St.Bin({ style_class: 'avatar-box' });
iconBox._size = size;
- let info = this._connections[conn.getPath()];
+ let info = this._connections[conn.get_object_path()];
if (!info)
- info = this.addConnection(conn.getPath());
+ info = this.addConnection(conn.get_object_path());
if (!info.icons[handle])
info.icons[handle] = [];
info.connectionAvatars.GetKnownAvatarTokensRemote([handle], Lang.bind(this,
function (tokens, err) {
let token = tokens && tokens[handle] ? tokens[handle] : '';
- this._avatarUpdated(conn, handle, token);
+ this._avatarUpdated(info.connectionAvatars, handle, token);
}));
}
Signals.addSignalMethods(ContactManager.prototype);
-function Source(accountPath, connPath, channelPath, targetHandle, targetHandleType, targetId) {
- this._init(accountPath, connPath, channelPath, targetHandle, targetHandleType, targetId);
+function Source(account, conn, channel) {
+ this._init(account, conn, channel);
}
Source.prototype = {
__proto__: MessageTray.Source.prototype,
- _init: function(accountPath, connPath, channelPath, targetHandle, targetHandleType, targetId) {
- MessageTray.Source.prototype._init.call(this, targetId);
+ _init: function(account, conn, channel) {
+ // FIXME: use chan.get_handle()
+ let props = channel.borrow_immutable_properties();
+ this._targetHandle = props[Tp.PROP_CHANNEL_TARGET_HANDLE];
+ this._targetHandleType = props[Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE];
+ this._targetId = channel.get_identifier();
- this.isChat = true;
+ MessageTray.Source.prototype._init.call(this, this._targetId);
- this._accountPath = accountPath;
+ this.isChat = true;
- let connName = Telepathy.pathToName(connPath);
- this._conn = new Telepathy.Connection(DBus.session, connName, connPath);
- this._channel = new Telepathy.Channel(DBus.session, connName, channelPath);
- this._closedId = this._channel.connect('Closed', Lang.bind(this, this._channelClosed));
+ this._account = account;
- this._targetHandle = targetHandle;
- this._targetHandleType = targetHandleType;
- this._targetId = targetId;
+ this._conn = conn;
+ this._channel = channel;
+ this._closedId = this._channel.connect('invalidated', Lang.bind(this, this._channelClosed));
- if (targetHandleType == Tp.HandleType.CONTACT) {
- let aliasing = new Telepathy.ConnectionAliasing(DBus.session, connName, connPath);
+ if (this._targetHandleType == Tp.HandleType.CONTACT) {
+ let aliasing = new Telepathy.ConnectionAliasing(DBus.session, conn.get_bus_name(), conn.get_object_path());
aliasing.RequestAliasesRemote([this._targetHandle], Lang.bind(this,
function (aliases, err) {
if (aliases && aliases.length)
// is a plausible default
this._presence = Tp.ConnectionPresenceType.AVAILABLE;
- this._channelText = new Telepathy.ChannelText(DBus.session, connName, channelPath);
+ this._channelText = new Telepathy.ChannelText(DBus.session, conn.get_bus_name(), channel.get_object_path());
this._sentId = this._channelText.connect('Sent', Lang.bind(this, this._messageSent));
this._receivedId = this._channelText.connect('Received', Lang.bind(this, this._messageReceived));
props[Tp.PROP_CHANNEL_CHANNEL_TYPE] = Tp.IFACE_CHANNEL_TYPE_TEXT;
props[Tp.PROP_CHANNEL_TARGET_HANDLE] = this._targetHandle;
props[Tp.PROP_CHANNEL_TARGET_HANDLE_TYPE] = this._targetHandleType;
- channelDispatcher.EnsureChannelRemote(this._accountPath, props,
+ channelDispatcher.EnsureChannelRemote(this._account.get_object_path(), props,
global.get_current_time(),
'',
Lang.bind(this, this._gotChannelRequest));